package com.ezops.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.ezops.filter.ReportCriteria;
import com.ezops.filter.ReportCriteria.Filter;
import com.ezops.service.IReportLocatorService;

/**
 * Class to location different kind of reports.
 * 
 * @author vgaurav
 * 
 */
@Component
public class ReportLocatorService implements IReportLocatorService {

	protected static Logger logger = LoggerFactory
			.getLogger(ReportLocatorService.class);

	@Value("${reports.basepath}")
	private String baseReportPath;


	/**
	 * TODO - Change the implementation later.
	 */
	@Override
	public String locate(ReportCriteria criteria) {
		logger.trace("location report starts");
		if (criteria == null) {
			throw new IllegalArgumentException(
					"Can not locate report with null criteria");
		}

		String reportName = criteria.getFilterValue(Filter.REPORT_NAME,
				String.class);

		return baseReportPath + reportName;
	}

}
